package com.lynn.salary.web.action;

import java.util.List;
import java.util.Map;

import com.lynn.salary.entity.Accessory;
import com.lynn.salary.entity.SystemFile;
import com.lynn.salary.service.IAccessoryService;
import com.lynn.salary.service.ISystemFileService;
import com.lynn.salary.util.ObjectFactory;

public class DownloadAction extends BaseAction {
	private ISystemFileService systemFileService = (ISystemFileService) ObjectFactory.getBean("systemFileService");
	private IAccessoryService accessoryService = (IAccessoryService) ObjectFactory.getBean("accessoryService");
	private Accessory accessory;
	private List<Map<String,Object>> files;
	private SystemFile systemFile;

	public String accessory() throws Exception {
		accessory = accessoryService.getByPk(accessory.getId(), accessory.getClass());
		if(accessory == null) {
			return "fileNotFound";
		} else {
			files = systemFileService.getPartByCondition(SystemFile.class, new String[]{"fileName","id"}, "tag like ?", new Object[]{"%"+accessory.getId()+"%"});
		}
		return "detail";
	}
	
	public String systemFile() throws Exception{
		
		return "downFile";
	}

	public Accessory getAccessory() {
		return accessory;
	}

	public void setAccessory(Accessory accessory) {
		this.accessory = accessory;
	}

	public List<Map<String, Object>> getFiles() {
		return files;
	}

	public void setFiles(List<Map<String, Object>> files) {
		this.files = files;
	}

	public SystemFile getSystemFile() {
		return systemFile;
	}

	public void setSystemFile(SystemFile systemFile) {
		this.systemFile = systemFile;
	}

	

}
